<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>总公司销售管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../res/css/wholesale/font.css">
  <link rel="stylesheet" href="../../res/css/wholesale/xadmin.css">
    <link rel="stylesheet" href="../../res/layuis/css/layui.css">
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript" src="../../res/layuis/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="../../res/js/wholesale/xadmin.js"></script>
<style type="text/css">
  .layui-table-view .layui-table {
	    position: relative;
	    margin: 0;
	    margin-bottom: 0px;
    }
</style>
</head>
<body>
<div class="demoTable" style="margin-top: 10px;">
 
    <div class="x-body" >
      <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
          <input type="text" name="sellId" id="sellId"    placeholder="销售订单号" autocomplete="off" class="layui-input"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <input type="date" name="startTime" id="startTime"   placeholder="销售开始时间" autocomplete="off" class="layui-input"> ——
          <input type="date" name="endTime" id="endTime"   placeholder="销售结束时间" autocomplete="off" class="layui-input"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <button class="layui-btn" data-type="reload" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </div>
      </div>
      
<table id = "sellTable" class="layui-table"  lay-data="{width:1480,url:'../../listenSell/selectAll.action', page:true, id:'idTest'}" lay-filter="demo">
  <!--  <thead >
    <tr>
      <th lay-data="{field:'sellId',width:160, align:'center'}">销售订单编号</th>
      <th lay-data="{field:'sellCompany',width:130, align:'center'}">销售公司</th>
      <th lay-data="{field:'sellTime',width:190, align:'center', templet: '#sellTime'}">销售时间</th>
      <th lay-data="{field:'sellPrice',width:140,  align:'center'}">销售总金额</th>
      <th lay-data="{field:'sellNumber',width:140, align:'center'}">销售总数量</th>
      <th lay-data="{field:'sellTarget',width:140,  align:'center'}">销售对象</th>
      <th lay-data="{field:'openTime',width:190, align:'center', templet: '#operationTime'}">操作时间</th>
      <th lay-data="{field:'oper', width:140, align:'center'}">操作人</th>
      <th lay-data="{field:'sellState',width:90,  align:'center'}">审核状态</th>
      <th lay-data="{field:'operation',width:151,  align:'center', toolbar: '#barDemo'}">操作</th>
    </tr>
  </thead>-->
</table>
 </div>
 </div>
<script src="../../res/js/wj/common.js" charset="utf-8"></script>

 <script type="text/html" id="sellTime">
  {{ formatDate(d.sellTime) }}  
</script>
<script type="text/html" id="operationTime">
  {{ formatDate(d.openTime) }}  
</script>
<script type="text/html" id = "sellStates">
	{{# if(d.sellState == 1) { }}
		<a class="layui-btn layui-btn-xs layui-btn-warm">等待总店财务审核</a>
	{{# }else if(d.sellState == 2) { }}
		<a class="layui-btn layui-btn-xs layui-btn-warm">等待总经理审核</a>
 	{{# }else if(d.sellState == 3) { }}
    	<a class="layui-btn layui-btn-xs layui-btn-normal">已审核</a>
 	 {{# } else if(d.sellState == 4){ }}
  		<a class="layui-btn layui-btn-xs layui-btn-danger">审核未通过</a>
	 {{# }}}
</script>
<script type="text/html" id = "barDemo">
		<a class="layui-btn layui-btn-xs" lay-event="detail">查看明细详情</a>
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use('table', function(){
  var table = layui.table;
  var $ = layui.$;
  table.render({
	    elem: '#sellTable'
	    ,page: true
	    ,url:'../../listenSell/selectAll.action'
	    ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
	    ,cols: [[
	       {field:'sellId', align:'center',title: '销售订单ID', sort: true}
	      ,{field:'sort', align:'center',title: '采购订单ID', sort: true}
	      ,{field:'companyName',width:165, align:'center',title: '销售对象'}
	      ,{field:'sellTime',width:165, align:'center',title: '销售时间', templet: '#sellTime'}
	      ,{field:'sellPrice', width:165,align:'center',title: '销售总金额'}
	      ,{field:'sellNumber',width:165, align:'center',title: '销售总数量',templet:'#sellNumber'}
	      ,{field:'openTime',width:165, align:'center',title: '操作时间', templet: '#operationTime'}
	      ,{field:'oper', width:165,align:'center',title: '操作人'}
	      ,{field:'sellState',width:165, align:'center',title: '审核状态',templet:'#sellStates'}
	      ,{field:'operation', width:165,align:'center',title: '操作' ,toolbar: '#barDemo'}
	    ]],id: 'idTest',done: function (res, curr, count) {
            $("[data-field='sellId']").css('display','none');
            $("[data-field='sort']").css('display','none');
            }
  });
  //监听表格复选框选择
  table.on('checkbox(demo)', function(obj){
    console.log(obj)
  });
  //表单重载
  var $ = layui.$, active = {
		    reload: function(){
			      var sellId = $('#sellId');
			      var startTime = $('#startTime');
			      var endTime = $('#endTime');
		      //执行重载    查询
		      table.reload('idTest', {
		        page: {
		          curr: 1 //重新从第 1 页开始
		        }
		        ,where: {
		        	sellId: sellId.val(),
		        	startTime: startTime.val(),
		        	endTime: endTime.val()
		        }
		      });
		    }
		  };
//监听工具条
  table.on('tool(demo)', function(obj){
    var da = obj.data;
    if(obj.event === 'detail'){
    	layer.open({
    		  type: 2, //设置为iframe
    		  area: ['70%', '80%'],
    		  content: ['../../pages/ListenSell/sellDetail.html?id='+da.sellId+'&ids='+da.sort+'', 'no'] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
    		  ,end: function(){ 
    		  }
    		  ,success: function(layero, index){
    			  iframe.load();
    		  }
    	  }); 
    }
  });
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});
</script>
</body>
</html>